-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Executor & data provider payouts #464
base: main
Are you sure you want to change the base?
Conversation
3f0c31f
to
9c23dc0
Compare
a269136
to
2eedbd8
Compare
0f4062f
to
bc9e427
Compare
bc9e427
to
ad59ae6
Compare
f9f3768
to
eefd206
Compare
6151add
to
70747b0
Compare
70747b0
to
dc86eb7
Compare
x/tally/keeper/endblock.go
Outdated
ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventTypeBaseFeeBurn, | ||
sdk.NewAttribute(sdk.AttributeKeyAmount, baseFee.String()), | ||
)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be easier if all attributes get emitted under a single event. If that's too much of a headache than we should at least add the DR_ID as an attribute so we can link the event to the relevant DR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DistributionsFromGasCalculation()
constructs a series of event attributes and emits them at once at the end. Since an attribute is just a key-value pair, proxy & executor gas attributes' values follow the "ID,amount" pattern.
vmRes, err := k.ExecuteTallyProgram(ctx, req, filterResult, reveals) | ||
if err != nil { | ||
result.Result = []byte(err.Error()) | ||
vmRes, tallyErr = k.ExecuteTallyProgram(ctx, req, filterResult, reveals) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The execution needs to be aware of the base gas fee that was already consumed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the base gas be taken from the execution gas limit while the tally program uses the tally gas limit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the base gas is charged from the tally gas limit. If we were to take it from the execution gas limit all the overlay nodes would also have to consider the base gas cost when calculating their individual limits. And we said it is to cover some of the computational load a DR causes for a validator that are not charged directly like the filter and tally VM; think basic consensus check, median gas price calculation, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK added. Perhaps BuildFilter()
should check if the filter gas cost is within the tally limit?
x/tally/keeper/payout.go
Outdated
} | ||
return dists, gasUsed.Uint64() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gasUsed
is not guaranteed to fit in a uint64 right? Lets say I change the price of my data proxy to 1 billion SEDA from 1 attoseda. Due to the delayed update the overlay computes its gas cost using the 1 attoseda fee but when the tally checks the price it has flipped and is now 1 billion SEDA.
Obviously an extreme example but think it's worth considering.
// GasCostBase is the base gas cost for a data request. | ||
uint64 gas_cost_base = 5; | ||
// GasCostCommit is the gas cost for a commit charged under certain scenarios. | ||
uint64 gas_cost_commit = 6; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is this used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We charge the base gas cost for every data request.
When the request times out or when there is no basic consensus, we charge the commit cost for each executor that did commit (CalculateCommitterPayouts()
)
x/tally/keeper/payout.go
Outdated
ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventTypeExecutorRewardUniform, | ||
sdk.NewAttribute(types.AttributeExecutor, executor), | ||
sdk.NewAttribute(sdk.AttributeKeyAmount, payout.String()), | ||
)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In terms of events I think we're only really interested in 2 values: medianGas
and lowestReporter
(which can be empty for uniform scenarios). This will allow us to simple add those attributes to the DR completion event and simplify indexing in that regard. The adjusted values after the shares calculation we will receive from the contract when it sends the actual SEDA amounts to the identities.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at the function DistributionsFromGasCalculation()
and let me know what you think. If we want those values, we can add those values to the GasCalculation
struct and emit them as events later, too.
x/tally/keeper/endblock.go
Outdated
} | ||
|
||
var execGasUsed uint64 | ||
if req.ReplicationFactor == 1 || areGasReportsUniform(gasReports) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not add the RF=1 case to areGasReportsUniform
? Since we check for 0 there as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the replication factor check and changed the check in areGasReportsUniform
to
if len(reports) <= 1 {
return true
}
… burn ratio gov param
Motivation
Implementation of data executor payout calculation and total execution gas consumption calculation in both uniform and divergent gas reporting scenarios.
See this table for broad descriptions of the payout logic.
Explanation of Changes
ErrInvalidFilterInput
,ErrNoConsensus
, or a tally VM execution errorRelated PRs and Issues
Closes #456 & #458